package com.mhc.haval.service.impl;

import com.mhc.haval.api.dto.AuditQuotaDTO;
import com.mhc.haval.api.service.IAuditQuotaService;
import com.mhc.haval.bo.AuditQuotaBO;
import com.mhc.haval.exception.HavalCommonException;
import com.mhc.haval.service.AuditQuotaService;
import com.subaru.common.util.BeanCopierUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import java.util.Optional;

/**
 * @author Churry
 * @create 2017-11-02 10:35
 **/
@RestController
public class IAuditQuotaServiceImpl implements IAuditQuotaService {

    @Autowired
    AuditQuotaService auditQuotaService;

    /**
     * 获取审批额度详情
     *
     * @param staffId
     * @return
     */
    @Override
    public AuditQuotaDTO getAuditQuotaDetailByStaffId(Long staffId) {
        Optional<Long> staffIdOptional = Optional.ofNullable(staffId);
        if (staffIdOptional.isPresent()) {
            AuditQuotaBO auditQuotaBO = auditQuotaService.getAuditQuotaDetailByStaffId(staffId);
            return BeanCopierUtil.convert(auditQuotaBO, AuditQuotaDTO.class);
        } else {
            throw new HavalCommonException("staffId cannot be null!");
        }
    }

}
